/**
 * 
 */
package com.ideazd.api.service;

import java.util.List;

import com.ideazd.api.model.NewDetails;
import com.ideazd.api.model.Propaganda;
import com.jfinal.kit.PropKit;
import com.jfinal.kit.StrKit;
import com.jfinal.plugin.activerecord.Page;

/**
 * @author yzz
 * @create 2016年3月26日 上午10:16:31
 */
public class NewsDetailsService {
	
	/**
	 * 根据类型查找
	 * @param picPosition
	 * @return
	 */
	public Page<NewDetails> newDetailsList(String pageIndex,String displayOrder,String detId){
		Page<NewDetails> newDetails = null;
		String sort = "createtime desc";
		
		if(displayOrder.equals("2")){
			sort = "readamount desc";
		}
		
		String notId = "";
		
		if(!StrKit.isBlank(detId)){
			notId = "and detid != '"+detId+"'";
		}
		
		String sql = "from sta_new_details where 1 = 1 "+notId+" and displaystatus = '1' order by "+sort+"";
		try {
			newDetails = NewDetails.dao.paginate(Integer.parseInt(pageIndex), Integer.parseInt(PropKit.get("firstLimit").toString()), "select * ", sql);
			return newDetails;
		} catch (Exception e) {
			System.out.println(e);
		}
		return null;
		
	}

}
